package com.dkd.manage.mapper;

import com.dkd.manage.annotation.AutoFill;
import com.dkd.manage.constant.OperationType;
import com.dkd.manage.pojo.dto.NodeQueryListDto;
import com.dkd.manage.pojo.entity.Node;
import com.dkd.manage.pojo.entity.Partner;
import com.dkd.manage.pojo.vo.NodeVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface NodeMapper {


    /**
     * 分页查询点位列表
     * @param nodeQueryListDto
     * @return
     */
    List<NodeVo> list(NodeQueryListDto nodeQueryListDto);


    /**
     * 新增点位
     * @param node
     * @return
     */
    @AutoFill(OperationType.INSERT)
    Integer add(Node node);

    /**
     * 修改合点位
     * @param node
     * @return
     */
    @AutoFill(OperationType.UPDATE)
    Integer edit(Node node);

    /**
     * 根据id查询合作商
     * @param id
     * @return
     */
    @Select("select id, partner_name, contact_person, contact_phone, profit_ratio, account, password, " +
            "create_time, update_time, create_by, update_by, remark from tb_partner where id = #{id}")
    Partner getPartnerById(Long id);

    /**
     * 根据id删除点位
     * @param ids
     * @return
     */
    Integer deleteNodeById(@Param("ids") Long[] ids);

    /**
     * 根据id查询点位
     * @param id
     * @return
     */
    @Select("select id, node_name, address, business_type, region_id, partner_id, " +
            "create_time, update_time, create_by, update_by, remark from tb_node where id = #{id}")
    Node getNodeById(Long id);

}
